package serivce

import (
	"guard/internal/app/user/models"
	"guard/internal/app/user/store"
	"guard/internal/tool"
)

type UserService interface {
	// Login 登录用
	Login(username, password string) (id int, userName string, err error)

	// UserInfo 用户信息返回
	UserInfo(token string) (uInfo models.UserInfo, err error)

	ServiceIndex
	ServiceAdmin
}

type userServiceImpl struct {
	st store.UserStore
}

func NewUserService(s store.UserStore) UserService {
	return &userServiceImpl{
		st: s,
	}
}

/**
下面接口向上组合
*/

// ServiceAdmin 用户管理service
type ServiceAdmin interface {
	UserPage(current, size int) (*tool.Paginator, error)
	QueryUser(condition string) (ud []*models.UserDto, err error)
	AddUser(user *models.User) error
	RemoveUser(username string) error
}

// ServiceIndex 用户操作service
type ServiceIndex interface {
	RegisterUser(user *models.User) error
	ModifyUserInfo(username, nickName, picTure string) error
	ModifyUserPassword(username, oldPwd, newPwd string) error
}
